﻿#ifndef PROPERTIESDLG_H
#define PROPERTIESDLG_H
#include <QSet>
#include <QMap>
#include <QDialog>
#include <QStringList>
#include <QTableWidget>
#include <QComboBox>
#include <QTableWidgetitem>
#include "globaldata.h"

class UnitInfoEditor;
class GraphicsRectItem;

namespace Ui
{
    class PropertiesDlg;
}

class PropertiesDlg : public QDialog
{
    Q_OBJECT

public:
    explicit PropertiesDlg(GraphicsRectItem *item, QWidget *parent = 0);
    ~PropertiesDlg();
    void initUI();
    void initPinsTable();
    void initConstautsTable();

    void closeEvent(QCloseEvent *event) override;

private slots:
    void on_handleCellChange(int row, int column);
    void on_addInputPin();
    void on_delInputPin();
    void on_addOutputPin();
    void on_delOutputPin();
    void on_closeButtonClick();
    void on_saveButtonClick();
    void on_updateButtonClick();
    void on_updateCurTableItem();

    void on_constantsHandleCellChange(int row, int column);
    void on_addConstaut();
    void on_delConstaut();

private:
    void setupTable();
    void connectSignals();
    void refreshTable();
    void refreshConstautsTable();
    Ui::PropertiesDlg* ui;
    QTableWidget* m_pInputTable = nullptr;
    QTableWidget* m_pOutputTable = nullptr;
    QTableWidget* m_pConstautsTable = nullptr;
    QTableWidgetItem* m_pCurTableItem = nullptr;
    GraphicsRectItem* m_rectItem = nullptr;
    UnitInfoEditor* m_unitInfoEditor = nullptr;
    Unit m_tempUnit;
};

#endif // PROPERTIESDLG_H
